<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('活动类型列表')" />
    <!-- html模块 -->
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <!-- 搜索栏信息设置 -->
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>活动类型名称：</p>
                                <input type="text" name="typeName"/>
                            </li>
                            <li>
                                <p>创建人：</p>
                                <input type="text" name="createBy">
                            </li>
                            <li>
                                <p>创建时间：</p>
                                <input type="text" class="time-input" id="createTime" placeholder="创建时间" />
                            </li>
                            <li>
                                <p>更新者：</p>
                                <input type="text" name="updateBy">

                            </li>
                            <li>
                                <p>更新时间：</p>
                                <input type="text" class="time-input" id="updateTime" placeholder="更新时间" />
                            </li>
                            <li>
                                <p>状态：</p>
                                <select name="state" th:with="type=${@dict.getType('sys_state_id')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                            th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <!-- 搜索按钮 -->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <!-- 增删改查按钮 -->
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="vtsp:type:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="vtsp:type:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="vtsp:type:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="vtsp:type:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <!-- 信息栏 -->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">
                    <thead>
                        <tr>
                            <th data-checkbox="true"></th>
                            <th data-formatter="fm_rowIndex" data-align="center">序号</th>
                            <th data-field="typeName">活动类型名称</th>
                            <th data-field="createBy">创建人</th>
                            <th data-field="createTime">创建时间</th>
                            <th data-field="updateBy">更新者</th>
                            <th data-field="updateTime">更新时间</th>
                            <th data-field="state"data-formatter="ty_state" data-align="center">状态</th>
                            <th data-field="memo">备注</th>
                            <th data-formatter="fm_commands" data-width="120px" data-align="center">操作</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <!-- JS模块 -->
    <script th:inline="javascript">
        //权限申请
        var editFlag = [[${@permission.hasPermi('vtsp:type:edit')}]];
        var removeFlag = [[${@permission.hasPermi('vtsp:type:remove')}]];
        var stateData = [[${@dict.getType('sys_state_id')}]];   //获取字典中的数据：状态
        var prefix = ctx + "vtsp/type";
        //初始化信息
        $(function()
            {
            var options =
                {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "活动类型",
                uniqueId: "typeId"
                };
            $.table.init(options);
            });
        //格式化字典数据
        function ty_state(value, row ,index)
        {
            return $.table.selectDictLabel(stateData, value);
        }

        //传递参数到后端
        function fm_commands(value, row, index)
        {
            var actions = [];
            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" ' +
                'onclick="$.operate.edit(\'' + row.typeId + '\' ,\'' +row.createBy + '\' ,\'' + row.createTime + '\' ,\''
                + row.updateBy + '\' ,\'' + row.updateTime + '\' ,\'' + row.state + '\' ,\'' + row.memo +
                '\')"><i class="fa fa-edit"></i>编辑</a> ');
            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" ' +
                'onclick="$.operate.remove(\'' + row.typeId + '\' ,\'' +row.createBy + '\' ,\'' + row.createTime + '\' ,\''
                + row.updateBy + '\' ,\'' + row.updateTime + '\' ,\'' + row.state + '\' ,\'' + row.memo +
                '\')"><i class="fa fa-remove"></i>删除</a>');
            return actions.join('');
        }
    </script>
</body>
</html>